Ext.define('AmpleHarvest.objects.metrics.sitesRollup.cToolBar',
{
	extend				: 'Ext.toolbar.Toolbar',
	alias				: 'widget.ampleharvest-objects-metrics-sitesrollup-ctoolbar',
	requires			:
	[
			'Ext.button.Button'
	],
	initComponent		: function()
	{
		this.callParent();
//		showDefault	: false,
//		addBtns		: true,
//		arr_btns	: [obj_openSelectedBtn ]
//		console.log(this.showDefault);
		if(this.showDefault != false)
		{
//			console.log('inside');
			this.m_obj_Up = Ext.create("Ext.button.Button",
			{
				text		: 'Up',
				iconCls		: "menu-group-add-icon",
				scope		: this,
				handler		: function()
				{
	
					// try passing a new target each time you navigate down
					var obj_siteView = this.up('ampleharvest-objects-metrics-sitesrollup-clist');
					var obj_linkTree = obj_siteView.getStore().first().get('link-tree').link;
					if (Ext.isObject(obj_linkTree)) {
						if(obj_linkTree['rel'] = 'container')
						{
							obj_siteView.load_path(obj_linkTree['href']);
						}
					}
					else if (Ext.isArray(obj_linkTree))
					{
						for (var i in obj_linkTree)
						{
							if(obj_linkTree[i]['rel'] == 'container')
							{
								var str_path = obj_siteView.util_metrics.buildLink(obj_linkTree[i]['urn']);
	//							var str_path = obj_siteView.util_metrics.stripServer(obj_linkTree[i]['href']);
								obj_siteView.load_store_from_path(str_path);
								obj_siteView.down('pagingtoolbar').moveFirst();
							}
						}
					}
				}
			});
			this.add(this.m_obj_Up);
			
			this.m_obj_Add = Ext.create("Ext.button.Button",
			{
				text		: 'Load Details',
				iconCls		: "menu-group-add-icon",
				scope		: this,
				handler		: function()
				{
					var obj_siteView = this.up('ampleharvest-objects-metrics-sitesrollup-clist');
					var recSelMod = this.up('ampleharvest-objects-metrics-sitesrollup-clist').getSelectionModel();
	
					var recs = recSelMod.getSelection();
					Ext.Array.each(recs, function(obj_linkTree, index, arr_all)
					{
						var obj_self = obj_linkTree.get('self');
	
						m_obj_AmpleHarvest_ViewPort
						.fireEvent(
								AmpleHarvest.eventHandler.cWindowEvents.C_STR_EVENT_METRICS_SITE_DETAIL,
								obj_siteView.util_metrics.buildLink(obj_self['urn'])
						);
					});
				}
			});
			this.add(this.m_obj_Add);
		}
		if(Ext.isArray(this.arr_btns))
		{
			for (var x in this.arr_btns)
			{
				this.add(this.arr_btns[x]);
			}
		}

		
		
	}
});